Python: Step by Step for Beginners: Easy Python for Everyone by M.O. Cuddley

Python: Step by Step for Beginners: Easy Python for Everyone by M.O. Cuddley

Author:M.O. Cuddley [Cuddley, M.O.]
Language: eng
Format: azw3
Published: 2017-06-25T04:00:00+00:00


In the code above, we added the statement “number1 + number2”. This is the code which actually adds the numbers supplied. Now, let’s store the value of number1 + number2 in a variable named total.

At this point, we’ll use another keyword, “return”. The return keyword exits a function. It tells Python “Hey, this is the end of this function” and optionally returns a value (the result of the action carried out by the function). If you don’t include a return statement in your function, it’ll return “None”. Let’s practice this. We’ll add a return statement to our “add_numbers” function to return the value of our variable, “total”.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.